package Controller;

/**
 * Classe responsavel por controlar e gerenciar os eventos relacionados ao itens 
 * especiais durante o jogo.
 * 
 * @author Edjane Catolle, Igor Henrique, Luiz Augusto, Vladmir Chicarolli
 * @version 1.0.0
 * @since 05/31/2011
 */

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import Model.ItemDestroyObstacleModel;
import Model.ItemFastPlayerModel;
import Model.ItemFastZombieModel;
import Model.ItemRefactor;
import Model.ItemSlowPlayerModel;
import Model.ItemSlowZombieModel;
import Model.ItemType;

public class ItemController extends BaseController implements ActionListener
{
	private ItemType currentChoice;
	private ItemRefactor itemRefactor;
	private Timer itemInterval;
	private int itemDelay = 5000;
	private int actionDelay = 5000;
	private boolean inItem = false;
	
	public ItemController()
	{
		itemRefactor = new ItemRefactor();
		this.itemInterval = new Timer(itemDelay, this);
		this.itemInterval.setInitialDelay(actionDelay);
	}
	
	protected void ControllerHandler() 
	{
		if(currentChoice != null)
		{
			switch (currentChoice) 
			{
				case SPEEDPLAYER:
					itemRefactor.setItem(new ItemFastPlayerModel());
				break;
				
				case SLOWPLAYER:
					itemRefactor.setItem(new ItemSlowPlayerModel());
				break;
				
				case SPEEDZOMBIE:
					itemRefactor.setItem(new ItemFastZombieModel());
				break;
				
				case SLOWZOMBIE:
					itemRefactor.setItem(new ItemSlowZombieModel());
				break;
				
				case DESTROYOBSTACLES:
					itemRefactor.setItem(new ItemDestroyObstacleModel());
				break;
			}
		}
	}

	@Override
	public void HandleKeyboard() 
	{

	}

	@Override
	public void actionPerformed(ActionEvent e)
	{
		//Novo item
		inItem = true;
		itemInterval.stop();
	}
	
	public void startItem()
	{
		this.itemInterval.start();
	}
}
